<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>返回CSR的主题</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.openssl-csr-get-subject" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">openssl_csr_get_subject</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0, PHP 7)</p><p class="refpurpose"><span class="refname">openssl_csr_get_subject</span> &mdash; <span class="dc-title">返回CSR的主题</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.openssl-csr-get-subject-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>openssl_csr_get_subject</strong></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$csr</code></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$use_shortnames</code><span class="initializer"> = true</span></span>
  ] ) : <span class="type">array</span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>openssl_csr_get_subject()</strong></span> 返回<code class="parameter">csr</code>中专有名称信息的主题，其中包含了通用名称 (CN), 机构名称 (O), 国家名 (C) 等字段。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.openssl-csr-get-subject-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

     
 <dt>
<code class="parameter">csr</code></dt>

 <dd>

  <p class="para">
   See <a href="openssl.certparams.html" class="link">CSR parameters</a> for a list of valid values.
  </p>
 </dd>


    
     <dt>
<code class="parameter">use_shortnames</code></dt>

     <dd>

      <p class="para">
       <code class="parameter">shortnames</code> 控制着数据如何在数组中被索引 - 如果 <code class="parameter">shortnames</code> 为 <strong><code>TRUE</code></strong> (默认) 将使用简称形式对字段进行索引，否则将使用全称形式 - 比如： CN 就是 commonName 的简称形式。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.openssl-csr-get-subject-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-function.openssl-csr-get-subject-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-926">
    <p><strong>Example #1 openssl_csr_get_subject() 范例</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$subject&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"countryName"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"CA"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"stateOrProvinceName"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"Alberta"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"localityName"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"Calgary"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"organizationName"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"XYZ&nbsp;Widgets&nbsp;Inc"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"organizationalUnitName"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"PHP&nbsp;Documentation&nbsp;Team"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"commonName"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"Wez&nbsp;Furlong"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"emailAddress"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"wez@example.com"</span><span style="color: #007700">,<br />);<br /></span><span style="color: #0000BB">$private_key&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">openssl_pkey_new</span><span style="color: #007700">(array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"private_key_bits"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">2048</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"private_key_type"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">OPENSSL_KEYTYPE_RSA</span><span style="color: #007700">,<br />));<br /></span><span style="color: #0000BB">$configargs&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'digest_alg'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'sha512WithRSAEncryption'<br /></span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$csr&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">openssl_csr_new</span><span style="color: #007700">(</span><span style="color: #0000BB">$subject</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$privkey</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$configargs</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">openssl_csr_get_subject</span><span style="color: #007700">(</span><span style="color: #0000BB">$csr</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [C] =&gt; CA
    [ST] =&gt; Alberta
    [L] =&gt; Calgary
    [O] =&gt; XYZ Widgets Inc
    [OU] =&gt; PHP Documentation Team
    [CN] =&gt; Wez Furlong
    [emailAddress] =&gt; wez@example.com
)
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.openssl-csr-get-subject-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="openssl_csr_new.html" class="function" rel="rdfs-seeAlso">openssl_csr_new()</a> - 生成一个 CSR</span></li>
    <li class="member"><span class="function"><a href="openssl_csr_get_public_key.html" class="function" rel="rdfs-seeAlso">openssl_csr_get_public_key()</a> - 返回CSR的公钥</span></li>
    <li class="member"><span class="function"><a href="openssl_x509_parse.html" class="function" rel="rdfs-seeAlso">openssl_x509_parse()</a> - 解析一个X509证书并作为一个数组返回信息</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>